package net.caixiaomi.info.ui.view;

import net.caixiaomi.info.model.DividerEntity;

import java.util.List;

/**
 * Created by mac on 2018/9/14.
 */

public class DividerParser {

    public int parseDivider(List<DividerEntity> data, int row){
        int length=data.size();
        if(length%row!=0){
            for(int i=0;i<length%row;i++){
                DividerEntity hall =new DividerEntity();
                data.add(hall);
                hall.empty=true;
            }
        }
        //常规加左上
        for(int i=0;i<length;i++){
            DividerEntity hall = (DividerEntity) data.get(i);
            hall.dividerType.add(DividerView.LEFT_TOP);
            if(i%row==row-1){
                hall.dividerType.add(DividerView.RIGHT);
            }
        }

        //最有一排加底部
        int count=length%row==0?length/row:length/row+1;

        for (int i = (count - 1) * row; i < length; i++) {
            DividerEntity hall = (DividerEntity) data.get(i);
            hall.dividerType.add(DividerView.BOTTOM);
        }
        return length%row;
    }
}
